package xps.and.uudaijia.userclient.view.activity;

import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.hitomi.cslibrary.CrazyShadow;
import com.hitomi.cslibrary.base.CrazyShadowDirection;
import com.jude.utils.JUtils;
import com.zhy.autolayout.AutoFrameLayout;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import xps.and.uudaijia.userclient.R;
import xps.and.uudaijia.userclient.util.CommonUtils;
import xps.and.uudaijia.userclient.view.base.BaseActivity;
import xps.and.uudaijia.userclient.view.fragment.MapViewFragment;

public class OrderDetailActivity extends BaseActivity {
    MapViewFragment mapViewFragment;
    @BindView(R.id.actionbar_al)
    AutoRelativeLayout actionbar_al;
    @BindView(R.id.actionbar_iv_back)
    ImageView actionbarIvBack;
    @BindView(R.id.actionbar_tv_title)
    TextView actionbarTvTitle;
    @BindView(R.id.actionbar_tv_right)
    TextView actionbarTvRight;
    @BindView(R.id.v_gap_line)
    View vGapLine;
    @BindView(R.id.container)
    FrameLayout container;
    @BindView(R.id.iv_driver_header)
    ImageView ivDriverHeader;
    @BindView(R.id.tv_driver_name)
    TextView tvDriverName;
    @BindView(R.id.iv_call_driver)
    ImageView ivCallDriver;
    @BindView(R.id.tv_start_time)
    TextView tvStartTime;
    @BindView(R.id.al_start_location)
    AutoLinearLayout alStartLocation;
    @BindView(R.id.tv_start_location)
    TextView tvStartLocation;
    @BindView(R.id.tv_end_location)
    TextView tvEndLocation;
    @BindView(R.id.al_order_panle)
    AutoLinearLayout al_order_panle;
    @BindView(R.id.af)
    AutoFrameLayout af;

    @Override
    protected int getLayout() {
        return R.layout.activity_order_detail;
    }

    @Override
    protected void setData() {

    }

    @Override
    protected void init() {
        ButterKnife.bind(this);
        mapViewFragment = new MapViewFragment();
        CommonUtils.replaceFragment(R.id.container, mapViewFragment, getSupportFragmentManager());
        mapViewFragment.setPinVisibility(View.INVISIBLE);
        addPlusButton();

        new CrazyShadow.Builder()
                .setContext(this)
                .setDirection(CrazyShadowDirection.BOTTOM)
                .setShadowRadius(JUtils.dip2px(3))
                .setBackground(getResources().getColor(R.color.white))
                .setImpl(CrazyShadow.IMPL_WRAP)
                .action(al_order_panle);
    }

    void addPlusButton() {
        ImageView imageView = new ImageView(this);
        imageView.setOnClickListener((v) ->
                JUtils.Toast("menu")
        );

        imageView.setOnLongClickListener((v) -> {
            JUtils.Toast("longclick menu");
            return false;
        });
        imageView.setImageResource(R.mipmap.more);
        int px = JUtils.dip2px(11);
        int pxright = JUtils.dip2px(2);
        imageView.setPadding(px,px,pxright,px);
        imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        AutoRelativeLayout.LayoutParams layoutParams = new AutoRelativeLayout.LayoutParams(AutoRelativeLayout.LayoutParams.WRAP_CONTENT, AutoRelativeLayout.LayoutParams.MATCH_PARENT);
        layoutParams.addRule(AutoRelativeLayout.ALIGN_PARENT_RIGHT);
        layoutParams.setMargins(40, 40, 0, 40);
        actionbar_al.addView(imageView, layoutParams);
    }

    @OnClick({R.id.actionbar_iv_back, R.id.iv_call_driver})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.actionbar_iv_back:
                break;
            case R.id.iv_call_driver:
                break;
        }
    }
}
